<form class="layui-form" action="">
  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">登录账号</label>
      <div class="layui-input-inline">
        <script type="text/html" template>
          <input type="text" name="admin_name" value="{{ d.params.admin_name || '' }}" lay-verify="required" placeholder="登录账号" autocomplete="off" class="layui-input">
        </script>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">管理组</label>

      <div class="layui-input-inline">
        <div class="layui-input-inline" lay-filter="layadmin-layout-right">
            <select name="group_id" id="parent_id" lay-verify="required">

            </select>
        </div>
      </div>

    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">登录密码</label>
      <div class="layui-input-inline">
        <script type="text/html" template>
          <input type="password" name="admin_pwd" placeholder="登录密码" autocomplete="off" class="layui-input">
          <span> *留空将不修改</span>
        </script>
      </div>
    </div>
    <script type="text/html" template>
      <input type="hidden" name="opt" value="edit">
      <input type="hidden" id="curr_parent" value="{{ d.params.group_id || '' }}">
      <input type="hidden" name="id" id="id" value="{{ d.params.admin_id || '' }}">
    </script>
    <div class="layui-form-item">
      <label class="layui-form-label"></label>
      <div class="layui-input-inline">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="确认" class="layui-btn">
      </div>
    </div>
  </div>
</form>
  <script>
      layui.use(['admin', 'form', 'upload'], function(){
          var $ = layui.$
              ,admin = layui.admin
              ,form = layui.form
              ,upload = layui.upload;
          var res;
          admin.req({
              url: layui.setter.api + 'admins/groupList'
              , method: 'get'
              , success: function (data) {
                  if (data.code == 0) {
                      var info = data.data;
                      var html = '<option value="0">选择分组</option>';
                      for (var key in info) {
                          var checked = '';
                          if($("#curr_parent").val() == info[key]['group_id']){
                              checked = 'selected';
                          }
                          html += '<option value="' + info[key]['group_id'] + '" '+checked+'>' + info[key]['group_name'] + '</option>'
                      }
                      $("#parent_id").html(html);
                      form.render();
                  }
              }
          });

      })
  </script>
